<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../layui/css/layui.css" media="all">
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend style="text-align: center">iArchie博客</legend>
</fieldset>
<div style="padding: 20px; background-color: #F2F2F2;">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">用户信息</div>
                <form action="" method="post">
                    <div class="layui-card-body">
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">文章标签:</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="text" name="queryBut" placeholder="请输入需要查询的文章标签"
                                           lay-verify="required" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">文章标题:</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="text" name="queryBut" placeholder="请输入需要查询的文章标题"
                                           lay-verify="required" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">作&nbsp;者:</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="text" name="queryBut" placeholder="请输入需要查询的作者"
                                           lay-verify="required" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <button class="layui-btn layui-btn-warm layui-btn-radius">点击查询</button>
                        </div>
                        <table id="demo" lay-filter="test"></table>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit" onclick="show()">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script src="../../layui/layui.js"></script>
<script>
    layui.use('table', function () {
        var table = layui.table;

        //第一个实例
        table.render({
            elem: '#demo'
            , height: 312
            , url: '../data/pinlun.json' //数据接口
            , page: true //开启分页
            , cols: [[ //表头
                {type: 'checkbox', fixed: 'left'}
                , {field: 'id', title: '文章ID', width: 90, sort: true}
                , {field: 'tags', title: '文章标签', width: 120}
                , {field: 'title', title: '文章标题', width: 325}
                , {field: 'author', title: '作者', width: 120}
                , {field: 'time', title: '上传时间', width: 160, sort: true}
                , {
                    fixed: 'right',
                    title: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;操作',
                    toolbar: '#barDemo',
                    width: 180
                }
            ]]
        });
        //监听行工具事件
        table.on('tool(test)', function (obj) {
            var data = obj.data;
            //console.log(obj)
            if (obj.event === 'del') {
                layer.confirm('真的删除数据吗', function (index) {
                    obj.del();
                    layer.close(index);
                });
            }
        });
    });

    function show() {
        layer.open({
            type: 2,
            area: ['45%', '350px'],
            title: '添加分类',
            skin: 'layui-layer-rim', //加上边框
            btn: ['保存', '取消'],
            btnAlign: 'c',
            top: 100,
            content: ['../common/layer_model3.html', 'no']
        });
    }

</script>
</body>
</html>